/*
 * @Author: CodeHare
 * @Date: 2023-10-30 10:51:56
 * @LastEditors: yangni 920556271@qq.com
 * @LastEditTime: 2024-04-23 17:20:42
 * @Description: EMS参数设置之电池设置
 */
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:yt_devops/resources/str_res_keys.dart';

class BatterySetModel {
  final batteryProtectParamsController1 = TextEditingController();
  final batteryProtectParamsController2 = TextEditingController();
  final batteryProtectParamsController3 = TextEditingController();
  final batteryProtectParamsController4 = TextEditingController();
  final batteryProtectParamsController5 = TextEditingController();
  final batteryProtectParamsController6 = TextEditingController();
  final batteryProtectParamsController7 = TextEditingController();
  final batteryProtectParamsController8 = TextEditingController();
  final batteryProtectParamsController9 = TextEditingController();
  final batteryProtectParamsController10 = TextEditingController();
  final batteryProtectParamsController11 = TextEditingController();
  final batteryProtectParamsController12 = TextEditingController();
  final batteryProtectParamsController13 = TextEditingController();
  final batteryProtectParamsController14 = TextEditingController();
  final batteryProtectParamsController15 = TextEditingController();
  final batteryProtectParamsController16 = TextEditingController();
  final batteryProtectParamsController17 = TextEditingController();
  final batteryProtectParamsController18 = TextEditingController();
  final batteryProtectParamsController19 = TextEditingController();
  final batteryProtectParamsController20 = TextEditingController();
  final batteryProtectParamsController21 = TextEditingController();
  final batteryProtectParamsController22 = TextEditingController();
  final batteryProtectParamsController23 = TextEditingController();
  final batteryProtectParamsController24 = TextEditingController();

  /// 电池设置的电池保护参数设置列表
  List<BatteryProtectParamsItem> get batteryProtectionParameterList => [
        BatteryProtectParamsItem(
            ResKey.deviceBatteryProtectionParameterSetting.tr,
            ResKey.deviceParameterSetting.tr,
            null,
            ""), //电池保护参数
        BatteryProtectParamsItem(ResKey.deviceSingleMaximumChargingVoltage.tr,
            "V", batteryProtectParamsController1, ""), //单体最高允许充电电压
        BatteryProtectParamsItem(
            ResKey.deviceOvervoltageOvervoltageEliminationValue.tr,
            "V",
            batteryProtectParamsController2,
            ""), //单体过压故障消除回差值
        BatteryProtectParamsItem(ResKey.deviceSingleMinimumChargingVoltage.tr,
            "V", batteryProtectParamsController3, ""), //单体最低允许充电电压
        BatteryProtectParamsItem(
            ResKey.deviceOvervoltageUndervoltageEliminationValue.tr,
            "V",
            batteryProtectParamsController4,
            ""), //单体欠压故障消除回差值
        BatteryProtectParamsItem(
            ResKey.deviceMaximumAllowableTemperatureCell.tr,
            "℃",
            batteryProtectParamsController5,
            ""), //单体最高允许温度
        BatteryProtectParamsItem(
            ResKey.deviceCellOvertemperatureEliminationDifference.tr,
            "℃",
            batteryProtectParamsController16,
            ""), //单体过温故障消除回差值
        BatteryProtectParamsItem(
            ResKey.deviceMinimumAllowableTemperatureCell.tr,
            "℃",
            batteryProtectParamsController7,
            ""), //单体最低允许温度
        BatteryProtectParamsItem(
            ResKey.deviceUndertemperatureEliminationDifference.tr,
            "℃",
            batteryProtectParamsController8,
            ""), //单体欠温故障消除回差值
        BatteryProtectParamsItem(ResKey.deviceMaximumAllowableVoltageBattery.tr,
            "V", batteryProtectParamsController9, ""), //电池组最高允许电压
        BatteryProtectParamsItem(
            ResKey.deviceBatteryStringOvervoltageErrorDifference.tr,
            "V",
            batteryProtectParamsController10,
            ""), //电池组过压故障回差值
        BatteryProtectParamsItem(
            ResKey.deviceMaximumAllowableChargingCurrentBattery.tr,
            "A",
            batteryProtectParamsController11,
            ""), //电池组最高允许充电电流
        BatteryProtectParamsItem(
            ResKey.deviceMaximumAllowableDischargingCurrentBattery.tr,
            "A",
            batteryProtectParamsController12,
            ""), //电池组最高允许放电电流
        BatteryProtectParamsItem(ResKey.deviceGeneralOverpressureLimit.tr, "V",
            batteryProtectParamsController13, ""), //一般过压限值
        BatteryProtectParamsItem(ResKey.deviceSevereOvervoltageLimit.tr, "V",
            batteryProtectParamsController14, ""), //严重过压限值
        BatteryProtectParamsItem(ResKey.deviceGeneralUndervoltageLimit.tr, "V",
            batteryProtectParamsController15, ""), //一般欠压限值
        BatteryProtectParamsItem(ResKey.deviceSevereUndervoltageLimit.tr, "V",
            batteryProtectParamsController16, ""), //严重欠压限值
        BatteryProtectParamsItem(ResKey.deviceGeneralChargingCurrentLimit.tr,
            "A", batteryProtectParamsController17, ""), //一般充电电流限值
        BatteryProtectParamsItem(ResKey.deviceSevereChargingCurrentLimit.tr,
            "A", batteryProtectParamsController18, ""), //严重充电电流限值
        BatteryProtectParamsItem(
            "", "A", batteryProtectParamsController19, ""), //一般放电电流限值
        BatteryProtectParamsItem(ResKey.deviceSevereDischargeCurrentLimit.tr,
            "A", batteryProtectParamsController20, ""),
        BatteryProtectParamsItem(ResKey.deviceGeneralOvertemperatureLimit.tr,
            "℃", batteryProtectParamsController21, ""), //一般过温限值
        BatteryProtectParamsItem(ResKey.deviceSevereOvertemperatureLimit.tr,
            "℃", batteryProtectParamsController22, ""), //严重过温限值
        BatteryProtectParamsItem(ResKey.deviceGeneralLowTemperatureLimit.tr,
            "℃", batteryProtectParamsController23, ""), //一般低温限值
        BatteryProtectParamsItem(ResKey.deviceSevereLowTemperatureLimit.tr, "℃",
            batteryProtectParamsController24, ""), //严重低温限值
      ].toList();

  set batteryProtectionParameterList(
      List<BatteryProtectParamsItem> updateList) {
    batteryProtectionParameterList = updateList;
  }

  /// 电池设置的系统使能设置列表
  List<BatteryEnableItem> get batteryEnableSetList => [
        BatteryEnableItem(ResKey.deviceSystemEnablingSettings.tr,
            ResKey.deviceParameterSetting.tr, ""), //系统使能设置
        BatteryEnableItem(
            ResKey.deviceSelfStartFunctionEnabled.tr, "", ""), //"自启动功能使能"
      ].toList();

  set batteryEnableSetList(List<BatteryEnableItem> updateList) {
    batteryEnableSetList = updateList;
  }

  BatterySetModel();
}

class BatteryProtectParamsItem {
  /// 描述
  String label;

  /// 单位
  String value;

  /// 控制器
  TextEditingController? textEditingController;

  /// 缓存值
  String previousValue;

  BatteryProtectParamsItem(
    this.label,
    this.value,
    this.textEditingController,
    this.previousValue,
  );
}

class BatteryEnableItem {
  /// 描述
  String label;

  /// 值
  String value;

  /// 缓存值
  String previousValue;
  BatteryEnableItem(
    this.label,
    this.value,
    this.previousValue,
  );
}
